<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>

<?php     
    
    $parent = 'clienteBusqueda';
    //variable de envio de informacion al menu Usuario ID
    $responseId         = $idUser;
    $idUser             = "idUser=".$idUser."&parent=".$parent;
    if (!$form->getObject()->isNew())
    $idUser            .= "&id=".$form->getObject()->getId();
    
    //Variable de la pagina
    $urlPage            = "LlamadaResultado";
    
    //Url de Actualizacion de Cliente Dashbioard
    $urlLoadUser        = "LoadUser('".url_for("dashboard/".$parent)."','".$idUser."','#User".$responseId."');";
    //Url de Actualizacion de Cliente Dashbioard / Cierre Ventana
    $urlLoadUserClose   = "javascritp:".$urlLoadUser."MenuClose();";
    //Url de Listar Atributos
    $urlListar          = "javascritp:LoadUser('".url_for('formulario/index'.$urlPage)."','".$idUser."','#slideDer-intConten');";
    //Url de Nuevo Atributo 
    $urlNew             = "javascritp:LoadUser('".url_for('formulario/new'.$urlPage)."','".$idUser."','#slideDer-intConten');";
    //Url de Delete Atributo 
    $urlDelete          = "javascritp:LoadUser('".url_for('formulario/delete'.$urlPage)."','".$idUser."','#slideDer-intConten');";
    
    
?>




<form class="filtroRangos" id="myForm<?php echo $urlPage; ?>" action="<?php echo url_for('formulario/'.($form->getObject()->isNew() ? 'createLlamadaResultado' : 'updateProgramarLlamada').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<table width="100%" cellpadding="0" cellspacing="0" border="0" id="tableRango">
    <tr>
        <td>
            <div class="title-windows">Programar respuesta de llamada
            
                <a href="javascript:void(0);" onclick="<?php echo $urlLoadUserClose; ?>" class="close-windows">
                    
                <img src="/images/icon/remove.png" title="Close"  />
                
                </a>
            </div>
        </td>
    </tr>
    <tr>
        <td class="" style="vertical-align:top; padding: 10px;">

        <?php if (!$form->getObject()->isNew()): ?>
        <input type="hidden" name="sf_method" value="put" />
        <?php endif; ?>


        <table width="100%" cellpadding="0" cellspacing="0" border="0">
      
      <tr>
          <td class="form-field" style="padding-top: 0px; margin-top: 0px;">

            <?php echo $form->renderGlobalErrors() ?>
            <?php echo $form['status'] ?>
            
            <?php if(empty($idLlamadaProgramada)){ ?>
            <?php echo $form['categoria_id']->renderLabel() ?>
            <?php echo $form['categoria_id']->renderError() ?>
              <div class="clear"></div>
             <?php  echo $form['categoria_id'];?>
            <div class="clear" style="height: 10px"></div>
            <?php  } else {?>
            Fecha de la Llamada Programada
            <div class="clear"></div>
            <p style="font-weight: bold; font-size: 14px"><?php  echo $form['fecha']->getValue();?> <p>
            <div class="clear" style="height: 10px"></div>
            
            <?php  } ?>
            Respuesta de la llamada
            <div class="clear"></div>
            <select name="llamada_programada[llamada_id]" id="llamada_programada_llamada_id">
            <?php
            
                        $llamadaNombreArray = '';


                        foreach ($llamadasStatus as $llamadasStatu){

                            $colorFondo[$llamadasStatu->getId()] = $llamadasStatu->getColorFondo();
                            $colorFuente[$llamadasStatu->getId()] = $llamadasStatu->getColorFuente();
                        }
                        foreach ($llamadasNombre as $llamadaNombre){

                            $llamadaNombreArray[$llamadaNombre->getLlamadaStatusId()] .= '<option value="'.$llamadaNombre->getId().'" style="color: '.$colorFuente[$llamadaNombre->getLlamadaStatusId()].'; background: '.$colorFondo[$llamadaNombre->getLlamadaStatusId()].'">'.$llamadaNombre->getNombre().'</option>';

                        }

                        foreach ($llamadasStatus as $llamadasStatu){

                    ?>
                        <optgroup label="Estatus <?php echo $llamadasStatu; ?>" style="color: <?php echo $llamadasStatu->getColorFuente(); ?>; background: <?php echo $llamadasStatu->getColorFondo(); ?>">
                                <?php echo $llamadaNombreArray[$llamadasStatu->getId()]; ?>
                        </optgroup>


            <?php } ?>          
            </select>
            <div class="clear" style="height: 10px"></div>
            <?php echo $form['nota']->renderLabel() ?>
            <?php echo $form['nota']->renderError() ?>
            <div class="clear"></div>
            <?php echo $form['nota'] ?>
        
              
         </td>
      </tr>  
  </table>


</td>
    </tr>
        <tr><td class="form-action-bottom">
            <!--Campo Oculto de evio de variable de ID del usuario-->
            <input type="hidden" name="idUser" value='<?php echo $responseId ?>'/>
            <input type="hidden" name="parent" value='<?php echo $parent ?>'/>
              
          
          <?php echo $form->renderHiddenFields(false) ?>
          <input class="button-submit" type="submit" value="Programar"  id="submit"/>
          <a class="button-done" href="javascript:void(0);" onclick="<?php echo $urlLoadUserClose; ?>">Cerrar</a>
    
        </td></tr>

    
  </table>


</form>
              
              

<!--Ejecucion del Formulario por Jquery para evitar recarga-->
<script type="text/javascript">
    
   
// prepare tde form when tde DOM is ready
$(document).ready(function() {
    var options = {
        target:        '#boxInput',   // target element(s) to be updated witd server response
        beforeSubmit:  showRequest,  // pre-submit callback
        success:       showResponse,  // post-submit callback
        type: 'post'       // 'get' or 'post', override for form's 'method' attribute

    };
    
    // bind form using 'ajaxForm'
    $('#myForm<?php echo $urlPage; ?>').ajaxForm(options);
});

// pre-submit callback
function showRequest(formData, jqForm, options) {
    // formData is an array; here we use $.param to convert it to a string to display it
    // but tde form plugin does tdis for you automatically when it submits tde data
    var queryString = $.param(formData);
    // here we could return false to prevent tde form from being submitted;
    // returning anytding otder tdan false will allow tde form submit to continue
    return true;
    
}

// post-submit callback
function showResponse(responseText, statusText, xhr, $form)  { 
    
     <?php echo $urlLoadUser; ?>
     //closeAll();      
     
}



</script>



